Path traversal protection in unzip to temp file#45691
Open
ayushhgarg-work wants to merge 9 commits intoAzure:mainfrom
Open
Path traversal protection in unzip to temp file#45691ayushhgarg-work wants to merge 9 commits intoAzure:mainfrom
ayushhgarg-work wants to merge 9 commits intoAzure:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens azure-ai-ml local job execution utilities against archive extraction vulnerabilities (ZipSlip/TarSlip) by validating ZIP members before extraction and adding a safer TAR extraction helper, along with new unit tests for the security behavior.
Changes:
- Add ZIP member validation to block path traversal before
extractall()inunzip_to_temporary_file. - Introduce
_safe_tar_extractalland use it when extracting the bootstrapper archive from a Docker container. - Add unit tests covering ZIP/TAR path traversal and link-handling scenarios.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| sdk/ml/azure-ai-ml/azure/ai/ml/operations/_local_job_invoker.py | Adds ZIP path validation and a safe TAR extraction helper; switches bootstrapper extraction to use the safer path. |
| sdk/ml/azure-ai-ml/tests/job_common/unittests/test_local_job_invoker.py | Adds unit tests for ZIP/TAR extraction safety and related rejection cases. |
You can also share your feedback on Copilot code review. Take the survey.
sdk/ml/azure-ai-ml/tests/job_common/unittests/test_local_job_invoker.py
Outdated
Show resolved
Hide resolved
sdk/ml/azure-ai-ml/tests/job_common/unittests/test_local_job_invoker.py
Outdated
Show resolved
Hide resolved
sdk/ml/azure-ai-ml/azure/ai/ml/operations/_local_job_invoker.py
Outdated
Show resolved
Hide resolved
sdk/ml/azure-ai-ml/tests/job_common/unittests/test_local_job_invoker.py
Outdated
Show resolved
Hide resolved
Member
Author
|
@microsoft-github-policy-service rerun |
Member
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes MSRC [110063] — two path traversal vulnerabilities in _local_job_invoker.py.
Fix 1: unzip_to_temporary_file now validates all ZIP member paths resolve within the target directory before extraction.
Fix 2: New _safe_tar_extractall helper replaces raw tarfile.extract() in copy_bootstrapper_from_container. Uses filter='data' on Python 3.12+; on older versions, manually blocks path traversal, symlinks, and hard links.
7 security regression tests added. All 10 tests passing, 0 regressions.